#include <random.h>

#define A 48271
#define M 2147483647
#define Q (M/A)
#define R (M%A)

static unsigned long Seed=1;

unsigned long _random(void)
{	long TmpSeed;
	TmpSeed=A*(Seed%Q)-R*(Seed/Q);
	if(TmpSeed >= 0)
		Seed=TmpSeed;
	else
		Seed=TmpSeed+M;
	
	return Seed;
}

void init_ramdom(unsigned long val)
{	Seed=val;
}
